import {create} from 'zustand'
import {createJSONStorage, devtools, persist} from 'zustand/middleware'

interface UserState {
    id: number,
    nickname: string,
    avatar: string,
}

const useUserStore = create(
    devtools(
        persist((set) => ({
                id: 0,
                nickname: '',
                avatar: '',
                setId: (id:number) => set({ id }),
                setNickname:(name:string)=>set({nickname:name}),
                setAvatar:(avt:string)=>set({avatar : avt})
            }),{
                name:'user-storage',
            }
        )
    )
)

export default  useUserStore
